package com.blrs.listener;

import com.blrs.domain.dto.ProjectPlanningDTO;
import com.blrs.service.project.planning.IProjectPlanningService;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 项目策划审批任务监听器
 */
@Slf4j
@Component
public class ProjectPlanningTaskListener implements TaskListener {

    @Autowired
    private IProjectPlanningService projectPlanningService;

    @Override
    public void notify(DelegateTask delegateTask) {
//        String eventName = delegateTask.getEventName();
//
//        if ("complete".equals(eventName)) {
//            // 获取流程变量
//            String planningId = (String) delegateTask.getVariable("planningId");
//            Boolean approvalResult = (Boolean) delegateTask.getVariable("approvalResult");
//            String approvalComments = (String) delegateTask.getVariable("approvalComments");
//
//            // 更新策划状态
//            ProjectPlanningDTO planningDTO = new ProjectPlanningDTO();
//            planningDTO.setPlanningId(planningId);
//            planningDTO.setAuditState(approvalResult ? "2" : "3"); // 2-已审核，3-已驳回
//
//            projectPlanningService.updateProjectPlanning(planningDTO);
//
//            // 记录日志
//            log.info("项目策划审批完成 - 策划ID: {}, 审批结果: {}, 审批意见: {}",
//                planningId, approvalResult, approvalComments);
//        }
    }
} 